// 服务页接口列表，this project is real tmd e xin

import request from '@/utils/request';
// 获取当前用户的服务中的订单
export function getInservice(patientId) {
  return request({
    url: `/patient/${patientId}/insurance_order/inservice`,
    method: 'get'
  });
}

// 获取当前登录人的关系列表
export function getFamilyData(patientId) {
  return request({
    // url: `/patient/${patientId}/insurance_orders/insureds`
    url: `/patients/${patientId}/familyMember`
  });
}

// 根据订单id获取服务单详情
export function getInserviceInfoByOrderId(orderId) {
  return request({
    url: `/patients/insurance_order/${orderId}`
  });
}

// 获取文章详情
export function getArticleDetail(articleId) {
  return request({
    url: `/wcm/articles/${articleId}`
  });
}

// 获取保障详情
export function getInsureDetail(id) {
  // id 为服务单id
  return request({
    url: `/insurance_orders/${id}/insurance_team_order`
  });
}

// 查询客户收件信息
export function getReceiverAddress(patientId) {
  return request({
    url: `/patients/${patientId}/receiverAddress`
  });
}

// 查询会员三定信息
export function getRegularMedicationInfo(patientId) {
  return request({
    url: `/patient/${patientId}/regularMedicationInfo`
  });
}

// 获取服务包介绍
export function getServiceIntroduce(insurance_package_id) {
  return request({
    url: `/insurance_packages/${insurance_package_id}/products`
  });
}
// 新增客户收件信息
export function createReceiverAddress(patientId, data) {
  return request({
    url: `/patients/${patientId}/receiverAddress`,
    method: 'POST',
    data
  });
}

// 编辑客户收件信息
export function editReceiverAddress(patientId, data, id) {
  return request({
    url: `/patients/${patientId}/receiverAddress/${id}`,
    method: 'PUT',
    data
  });
}

// 删除客户收件信息
export function delReceiverAddress(patientId, id) {
  return request({
    url: `/patients/${patientId}/receiverAddress/${id}`,
    method: 'DELETE'
  });
}

// 查询被保人三定信息 tmd
export function existEstimatedOrder(insuredId) {
  // insuredId 为被报人的patientid
  return request({
    url: `/patients/${insuredId}/existEstimatedOrder?ignoreFirstOrder=true`,
    method: 'GET'
  });
}

// 忽略是否是首次提交三定送药信息
export function ingoreFirstExistEstimatedOrder(insuredId) {
  // insuredId 为被报人的patientid
  return request({
    url: `/patients/${insuredId}/existEstimatedOrder?ignoreFirstOrder=false`,
    method: 'GET'
  });
}

// 根据服务包查询产品的产品文档
export function getPackageArticle(insurancePackageId) {
  return request({
    url: `/insurance_packages/${insurancePackageId}/products`,
    method: 'GET'
  });
}
// 查询会员信息

export function getPatientInfo(patientId) {
  return request({
    url: `/patient/${patientId}`,
    method: 'GET'
  });
}

// 查询被保险人保单
export function getInsuranceOrder(patientId) {
  return request({
    url: `/insuranceOrder?insuredId=${patientId}`,
    method: 'GET'
  });
}
// 查询多人保单列表
export function getFamilyInsuranceOrder(patientIdListStr) {
  return request({
    url: `/insuranceOrder?insuredIds=${patientIdListStr}`,
    method: 'GET'
  });
}

// 根据服务包id查问询
export function getinquiries(packageId) {
  return request({
    url: `/insurance_package/${packageId}/inquiries`,
    method: 'GET'
  });
}
// 健康视频
export function getVideoList(where, skip, limit) {
  return request({
    url: `/wcm/articles?where=${where}&skip=${skip}&limit=${limit}`,
    noAuth: true,
    // noqs: true,
    method: 'get'
  });
}
// 获取最后一个有效订单的配送时间
export function getLastDeliveryTime(patientId) {
  // 项目类型 15 写死了
  return request({
    url: `/orders/patient/${patientId}/lastDeliveryTime?channel=15`,
    method: 'get'
  });
}

// 查询用户支付订单 (默认取公益项目来源的订单)
export function getpayNum(patientId) {
  // 项目类型 15 写死了
  return request({
    url: `/payOrders/patients/${patientId}`,
    method: 'get'
  });
}

// 查询机构送货方式
export function salesCatalog(catalogId) {
  // 项目类型 15 写死了
  return request({
    url: `/salesCatalog/${catalogId}`,
    method: 'get'
  });
}

// 获取问诊记录
export function getWxaRecords(patientId) {
  return request({
    url: `/patients/${patientId}/wxaRecords`,
    method: 'get'
  });
}

// 获取家人问诊记录

export function getFamilyWxaRecords(patientIdListStr) {
  return request({
    url: `/patients/wxaRecords?patientIds=${patientIdListStr}`,
    method: 'get'
  });
}

// 获取用户和缓医生订单信息
export function getMedicOrderInfo(patientId) {
  return request({
    url: `/patients/${patientId}/medicOrderInfo`,
    method: 'get'
  });
}

// 获取所有保单

export function getInsuranceList(patientId, data) {
  console.log('getInsuranceList data:', data);
  let queryStr = '';
  let keys = Object.keys(data);
  for (let key of keys) {
    queryStr += key + '=' + data[key] + '&';
  }
  return request({
    url: `/patients/${patientId}/familyInsurances?${queryStr}`,
    method: 'get'
  });
}
